package com.amex.uam.dao;


import java.util.Collection;
import java.util.Date;
import java.util.List;

import com.amex.uam.model.MSLogin;
import com.amex.uam.model.Message;
import com.amex.uam.model.SecurityGroupBean;
import com.microstrategy.web.beans.UserGroupBean;
import com.microstrategy.web.objects.WebFolder;
import com.microstrategy.web.objects.WebIServerSession;
import com.microstrategy.web.objects.WebObjectInfo;
import com.microstrategy.web.objects.WebObjectSource;
import com.microstrategy.web.objects.admin.users.WebUser;
import com.microstrategy.web.objects.admin.users.WebUserEntity;
import com.microstrategy.web.objects.admin.users.WebUserGroup;
import com.microstrategy.webapi.EnumDSSXMLAccessRightFlags;

public interface MstrDao {

	int ACL_Browse = EnumDSSXMLAccessRightFlags.DssXmlAccessRightBrowse;// = 1;
	/** @deprecated */
	int ACL_UseExecute = EnumDSSXMLAccessRightFlags.DssXmlAccessRightUseExecute;// = 2;
	int ACL_Read = EnumDSSXMLAccessRightFlags.DssXmlAccessRightRead;// = 4;
	int ACL_Write = EnumDSSXMLAccessRightFlags.DssXmlAccessRightWrite;// = 8;
	int ACL_Delete = EnumDSSXMLAccessRightFlags.DssXmlAccessRightDelete;// = 16;
	int ACL_Control = EnumDSSXMLAccessRightFlags.DssXmlAccessRightControl;// = 32;
	int ACL_Use = EnumDSSXMLAccessRightFlags.DssXmlAccessRightUse;// = 64;
	int ACL_Execute = EnumDSSXMLAccessRightFlags.DssXmlAccessRightExecute;// = 128;
	int ACL_FullControl = EnumDSSXMLAccessRightFlags.DssXmlAccessRightFullControl;// = 255;
	int ACL_Inheritable = EnumDSSXMLAccessRightFlags.DssXmlAccessRightInheritable;// = 536870912;
	
	public static enum BaseGroup {
		
		MARC ("MARC"), 
		Privileges ("Privileges"); 
		
		private String name;
		private BaseGroup(String name){
			this.name = name;
		}
		public String getName() {
			return name;
		}
	}
	
	SecurityGroupBean getGroup(BaseGroup group, WebIServerSession session);
	
	SecurityGroupBean getGroup(String groupName, WebIServerSession session);
	
	SecurityGroupBean getGroup(String baseId, WebIServerSession session, int level);
	
	UserGroupBean createGroup(String groupName, WebIServerSession session);
	UserGroupBean createGroup(String groupName, WebIServerSession session, boolean validate);
	
	Message addMemberGroup(String parentGroupName, String childGroupName, WebIServerSession session);
	Message addMemberGroups(String parentGroupName, Collection<String> childGroupNames, WebIServerSession session);
	
	Message addParentGroups(String childGroupName, Collection<String> parentGroupNames, WebIServerSession session);
	
	WebIServerSession getAdminSession(MSLogin user);
	
	List<SecurityGroupBean> getUserGroups(String userName, WebIServerSession session);

	List<SecurityGroupBean> getUserGroups(WebIServerSession session);
	
	boolean attachUserToGroup(String userName, String groupName, WebIServerSession session);
	
	boolean removeUserFromGroup(String userName, String groupName, WebIServerSession session);
	
	WebUser searchUser(String userName, WebIServerSession session);
	WebUser searchUser(String userName, WebObjectSource source);

	WebUserGroup searchUserGroup(String groupName, WebObjectSource source);

	WebUserGroup searchUserGroup(String groupName, WebIServerSession managerSession);
	
	/*********************
	 * User
	 ********************/
	boolean activateUser(String userId, boolean isActivate, WebIServerSession session);
	boolean removeUser(String userId, WebIServerSession session);
	boolean setPasswordExpirationDate(String userId, Date date, WebIServerSession session);
	/*********************
	 * ACL
	 ********************/
	@Deprecated
	boolean grantACLToFolder(String targetName, String trusteeName, WebIServerSession session);
	boolean grantACLToSharedReportsFolder(String userGroupId, String folderId, WebIServerSession session);
	boolean removeACL(WebObjectInfo target, String trusteeName, WebIServerSession session);	
	boolean removeACL(WebObjectInfo target, WebUserEntity trustee, WebIServerSession session);
	/********************
	 * Folder
	 ********************/
	WebFolder getTeamSharedReportsFolder(WebIServerSession session, String folderName);
	WebFolder getTeamSharedReportsFolder(WebObjectSource source, String folderName);

	WebFolder getSubFolder(WebIServerSession session, String rootFolderId, String subFolderName);
	WebFolder getSubFolder(WebObjectSource source, String rootFolderId, String subFolderName);

	WebFolder createFolder(WebFolder parentFolder, String folderName, WebIServerSession session);
	WebFolder createFolder(WebFolder parentFolder, String folderName, WebObjectSource source);

	WebFolder searchFolder(String folderName, WebIServerSession managerSession);

}
